# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer:  Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=perl-io-compress
_pkgname=IO-Compress
pkgver=2.096
pkgrel=0
pkgdesc="Perl compression library"
url="https://metacpan.org/release/IO-Compress"
arch="noarch"
license="GPL-1.0-or-later OR Artistic-1.0-Perl"
depends="perl perl-compress-raw-bzip2 perl-compress-raw-zlib"
makedepends="perl-dev"
source="https://cpan.metacpan.org/authors/id/P/PM/PMQS/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

prepare() {
	default_prepare
	export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
	PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
}

build() {
	export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
	make
}

check() {
	export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
	make test
}

package() {
	export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
	make DESTDIR="$pkgdir" install

	# conflicts with core perl
	rm "$pkgdir"/usr/bin/zipdetails
	rmdir "$pkgdir"/usr/bin 2>/dev/null || true

	# creates file collision among perl modules
	find "$pkgdir" \( -name perllocal.pod -o -name .packlist \) -delete

	# man pages are already provided by perl-doc
	rm -rf "$pkgdir"/usr/share/man
}

sha512sums="e23ee6fe9585aa33c1936d045bfe4a339a159085b999da4b54101a6b400ff4af941193bd40df41eff5c9f38cf7097d69044c6472666759b80769e1b6e1db60c3  IO-Compress-2.096.tar.gz"
